Expand description

A clipboard library providing useful extensions for the copypasta library.

Here are some of these additions:

Example

Get and set clipboard contents. Tries to select the correct clipboard context at runtime using try_context. Useful if you just want quick access to the clipboard, and if you don’t want to implement any clipboard context selecting logic yourself.

let mut ctx = copypasta_ext::try_context().expect("failed to get clipboard context");
println!("{:?}", ctx.get_contents());
ctx.set_contents("some string".into()).unwrap();

Get and set clipboard contents. Keeps contents in X11 clipboard after exit by forking the process (which normally doesn’t work with copypasta’s X11ClipboardContext). Falls back to standard clipboard provider on non X11 platforms. See x11_fork module for details.

use copypasta_ext::prelude::*;
use copypasta_ext::x11_fork::ClipboardContext;

let mut ctx = ClipboardContext::new().unwrap();
println!("{:?}", ctx.get_contents());
ctx.set_contents("some string".into()).unwrap();

Get and set clipboard contents. Keeps contents in X11 clipboard after exit by invoking xclip/xsel. Falls back to standard clipboard provider on non X11 platforms. See x11_bin module for details.

use copypasta_ext::prelude::*;
use copypasta_ext::x11_bin::ClipboardContext;

let mut ctx = ClipboardContext::new().unwrap();
println!("{:?}", ctx.get_contents());
ctx.set_contents("some string".into()).unwrap();

Requirements

  • Rust 1.47 or above
  • Same requirements as copypasta
  • Requirements noted in specific clipboard context modules

Re-exports

pub use copypasta;

Modules

Display server management.

OSC 52 escape sequence to set clipboard contents.

Trait prelude.

Invokes wl-copy/wl-paste to access clipboard.

Invokes xclip/xsel to access clipboard.

Like x11_clipboard, but forks to set contents.

Structs

Combined, use different clipboard context for getting & setting.

Functions

Try to get clipboard context.

Type Definitions

Copypasta result type, for your convenience.